<template>
<div class="container">
	<div class="title">环境配置</div>
	<div class="item">
		<el-button :type="currentVersion === '' || currentVersion === 'php'  ? 'primary' : 'default'" @click="chooseVersion('php')">选择php接口</el-button>
		<el-button :type="currentVersion === 'go'  ? 'primary' : 'default'" @click="chooseVersion('go')">选择golang接口</el-button>
	</div>
</div>
</template>

<script setup>
import { ElMessage, ElButton } from "element-plus";
import Methods from "../utils/Methods";
import config from "../utils/config";
import {ref} from "vue";
const currentVersion = ref('')

const chooseVersion = (type) => {
	if (type === 'php') {
		currentVersion.value = 'php'
		Methods.setLocalStorage('api_url',config.baseUrl)
	}else if (type === 'go') {
		currentVersion.value = 'go'
		Methods.setLocalStorage('api_url',config.baseUrlGo)
	}
	ElMessage.success('已设置')
}
const checkApiVersion = () => {
	let api_url = Methods.getLocalStorage('api_url')
	if (!api_url) {
		currentVersion.value = 'php'
	}else if (api_url === config.baseUrl) {
		currentVersion.value = 'php'
	}else if (api_url === config.baseUrlGo) {
		currentVersion.value = 'go'
	}
}
checkApiVersion()
</script>
<style lang="scss" scoped>
.container {
	box-sizing: border-box;
	padding: 15px;
}
.title {
	font-size: 18px;
	margin-bottom: 15px;
}
.item {

}
</style>